package entity

import (
	"shqsoft.cn/pasnj/base"

	"github.com/jinzhu/gorm"
)

//WBCKDR 外币存款导入
type WBCKDR struct {
	ID   int     `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	KHYF int     `gorm:"column:KHYF"`
	KHJL string  `gorm:"column:KHJL;size:100"`
	RJ   float64 `gorm:"column:RJ"`
}

//WbckAfterImport 导入后执行
func WbckAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	err = tx.Exec("UPDATE T_BASE_YXFY_WBCK SET EMID=B.ID "+
		"FROM T_BASE_YXFY_WBCK A INNER JOIN T_SysUser B ON (A.KHJL=B.SysUserName) OR (A.KHJL=B.SysUserID)"+
		"WHERE KHYF=?", params["KHYF"]).Error
	if err != nil {
		return err
	}
	return nil
}

//TableName 外币存款导入表
func (WBCKDR) TableName() string {
	return "T_BASE_YXFY_WBCK"
}

//WBCKDREF 返回结构体
func WBCKDREF() base.EntityFunc {
	return func() interface{} {
		entity := WBCKDR{}
		return &entity
	}
}

//WBCKDRESF 返回结构体数组
func WBCKDRESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []WBCKDR
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("WBCKDR", base.NewDefaultDao(WBCKDREF(), WBCKDRESF(), nil))
	base.SetAfterCallBack("WBCKDR", WbckAfterImport)
}
